import {Component, OnInit} from '@angular/core';
import {_HttpClient} from '@delon/theme';
import {UtilityService} from '../../../../service/utils.service';
import {NzModalService, NzNotificationService} from 'ng-zorro-antd';
import {ActivatedRoute, Router} from '@angular/router';
import {appConfig} from '../../../../service/common';


@Component({
  selector: 'app-fieldper',
  templateUrl: './fieldper.component.html',
})
export class FieldperComponent implements OnInit {
    roleGuid: string;
    constructor(
        private http: _HttpClient,
        private router: Router,
        private activatedRoute: ActivatedRoute, // 注入路由，接收到参数
        private nznot: NzNotificationService,
        private utilityService: UtilityService,
    ) { }


 _dataSet = [];
  _bordered = true;
  _loading = false;
  _pagination = true;
  _header = true;
  _title = true;
  _footer = true;
  _fixHeader = false;
  _size = 'small';
    roleName: string;
    roleCode: string
    ngOnInit() {
        this.roleGuid = this.activatedRoute.snapshot.params.id; // 拿到父组件传过来的组织机构的guid来进行操作
        this.queryRoleData(this.roleGuid)
        for (let i = 1; i <= 10; i++) {
             this._dataSet.push({
        key        : i,
        name       : 'John Brown',
        age        : `${i}2`,
        address    : `New York No. ${i} Lake Park`,
        description: `My name is John Brown, I am ${i}2 years old, living in New York No. ${i} Lake Park.`,
      });
        }
  }


    // 根据guid查询角色消息
    queryRoleData(id) {
        this.utilityService.getData(appConfig.serverUrl +  appConfig.API.queryRoleById + '/' + id)
            .subscribe(
                (val) => {
                    console.log(val)
                    this.roleName = val.result.roleName;
                    this.roleCode = val.result.roleCode;
                });
    }


    isNull = true;
    dataAddModal = false;
    operate = false;
      headerData = [  // 配置表头内容
        {value: '属性名称', key: 'dataEntity',  isclick: false},
        {value: '列名称' , key: 'applyName', isclick: true},
        {value: '类型/长度' , key: 'viewRange', isclick: true},
        {value: '可修改值', key: 'manageableRange',  isclick:  false},
        {value: '可查询值' , key: 'customRange', isclick: false},
        {value: '属性描述' , key: 'customRange', isclick: false},
    ];
    showAdd = false;
    panels = [
    {
      active: true,
      name: 'This is panel header 1',
      childPanel: [
        {
          active: false,
          name: 'This is panel header 1-1'
        }
      ]
    },
    {
      active: false,
      name: 'This is panel header 2'
    },
    {
      active: false,
      name: 'This is panel header 3'
    }
  ];

}
